<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./vue.min.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="app">
        <div id="demo">
            {{num}}
        </div>
        <div>
            <button @click="add">Add</button>
            <button @click='reduce'>reduce</button>
        </div>
    </div>
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                num: 10
            },
            methods: {
                add: function () {
                    this.num++;
                }
            }
        })
        app.$on('reduce',function () {
            this.num--;
        })
        function reduce() {
            app.$emit('reduce');
        }
    </script>
</body>

</html>